<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * autores: Carlos Castillo 
 */
class solicitud {
    private  $idEmisor;
    private  $idReceptor;
    private  $descripcion;
    
    
    public function getIdEmisor() {
        return $this->idEmisor;
    }

    public function setIdEmisor($idEmisor) {
        $this->idEmisor = $idEmisor;
    }

    public function getIdReceptor() {
        return $this->idReceptor;
    }

    public function setIdReceptor($idReceptor) {
        $this->idReceptor = $idReceptor;
    }

    public function getDescripcion() {
        return $this->descripcion;
    }

    public function setDescripcion($descripcion) {
        $this->descripcion = $descripcion;
    }

       
   
    public function __construct($emisor,$receptor,$descripcion){
        if (!isset($_SESSION))
            session_start();
        $this->idEmisor = $emisor;
        $this->idReceptor = $receptor;
        $this->descripcion = $descripcion;
        
    }
   
    public function anadir_solicitud(){
        include_once($_SESSION['dir'].'/basedatos.php');
        $baseD = new BaseDatos('solicitud');
        $baseD -> agregarSolicitud($this->idEmisor , $this->idReceptor, $this->descripcion);
    }
   
    public function eliminar_solicitud(){
        include_once($_SESSION['dir'].'/basedatos.php');
        $baseD = new BaseDatos('solicitud');
        $baseD -> eliminarSolicitud($this->idEmisor,  $this->idReceptor);
    }
    
    public function buscar_solicitudes() {
        include_once($_SESSION['dir'].'/basedatos.php');
        $baseD = new BaseDatos('solicitud');
        $aux = $baseD ->buscarSolicitud($this->idReceptor);
        $retorno = array();
        $k = 0;
        for($i = 0; $i < sizeof($aux); ++$i)
           for($j = 0; $j < 4; ++$j)
             if($j!=1&&$j!=3)
                $retorno[$k++] = $aux[$i][$j];
             
        return $retorno;
    }
}

?>
